import request from '@/utils/request'

export const paymentService = {
    // 创建支付订单
    createPayment(bookingId) {
        return request({
            url: '/payment/create',
            method: 'post',
            params: { bookingId }
        })
    },
    
    // 通过课程安排ID创建支付订单
    createPaymentByScheduleId(scheduleId) {
        return request({
            url: '/payment/create/schedule',
            method: 'post',
            params: { scheduleId }
        })
    },
    
    // 获取支付宝支付表单
    getAlipayForm(orderNo) {
        return request({
            url: '/payment/alipay',
            method: 'get',
            params: { orderNo }
        })
    },
    
    // 查询支付订单状态
    getPaymentStatus(orderNo) {
        return request({
            url: '/payment/status',
            method: 'get',
            params: { orderNo }
        })
    },
    
    // 获取学生的支付订单列表
    getStudentPayments() {
        return request({
            url: '/payment/student/list',
            method: 'get'
        })
    },
    
    // 获取教师的收款订单列表
    getTeacherPayments() {
        return request({
            url: '/payment/teacher/list',
            method: 'get'
        })
    },
    
    // 手动更新支付状态（临时解决方案）
    manualUpdatePaymentStatus(orderNo, tradeNo) {
        return request({
            url: '/payment/manual-update',
            method: 'post',
            params: { 
                orderNo,
                tradeNo 
            }
        })
    }
} 